/**
 * 
 */
package com.zyj.blog.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.zyj.blog.http.HttpResult;
import com.zyj.blog.pojo.SysMenu;
import com.zyj.blog.service.SysMenuService;

/**
 * @author zyj
 *
 */
@RestController
@RequestMapping("/menu")
public class SysMenuController {
	
	@Autowired
	private SysMenuService sysMenuService;

	@GetMapping(value="/findMenuTree")
	public HttpResult findMenuTree() {
		return HttpResult.ok(sysMenuService.findTree(null, 0));
	}
	
	@GetMapping(value="/findNavTree")
	public HttpResult findNavTree(@RequestParam String username) {
		return HttpResult.ok(sysMenuService.findTree(username, 1));
	}
	
	@PostMapping(value="/save")
	public HttpResult save (@RequestBody SysMenu record) {
		return HttpResult.ok(sysMenuService.save(record));
	}
	
	@PostMapping(value="/delete")
	public HttpResult delete(@RequestBody List<SysMenu> records) {
		return HttpResult.ok(sysMenuService.delete(records));
	}
}
